class Solution {
    public int findMin(int[] nums) {
        int left = 0, right = nums.length - 1, ans = 1000000, pivot;
        while (left <= right) {
            pivot = (left+right)/2;
            if (nums[left] <= nums[pivot]){
                ans = Math.min(ans, nums[left]);
                left = pivot + 1;
            } else {
                ans = Math.min(ans, nums[pivot]);
                right = pivot - 1;
            }
        }
        return ans;
    }
}